class Solution {
public:
    int countone(int n)
    {
        int res=0;
        while(n)
        {
            if(n%10==1)
                res++;
            n/=10;
        }
        return res;
    }
    int NumberOf1Between1AndN_Solution(int n) {
        int res=0;
        for(int i=1;i<=n;i++)
        {
            res+=countone(i);
        }
        return res;
    }
};